unit DopPodrView;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dRoot, DB, StdCtrls, Buttons, ExtCtrls, ComCtrls, cxStyles,
  dxSkinsCore, dxSkinBlack, dxSkinBlue, dxSkinCaramel, dxSkinCoffee,
  dxSkinDarkSide, dxSkinGlassOceans, dxSkiniMaginary, dxSkinLilian,
  dxSkinLiquidSky, dxSkinLondonLiquidSky, dxSkinMcSkin, dxSkinMoneyTwins,
  dxSkinOffice2007Black, dxSkinOffice2007Blue, dxSkinOffice2007Green,
  dxSkinOffice2007Pink, dxSkinOffice2007Silver, dxSkinPumpkin,
  dxSkinSilver, dxSkinStardust, dxSkinSummer2008, dxSkinsDefaultPainters,
  dxSkinValentine, dxSkinXmas2008Blue, dxSkinscxPCPainter, cxCustomData,
  cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, cxDBData,
  cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGrid, IBCustomDataSet,
  IBQuery, dxdbtrel;

type
  TfmDopPodrView = class(TdlgRoot)
    Panel2: TPanel;
    dsSD: TDataSource;
    qSD: TIBQuery;
    qSDSDID: TIntegerField;
    qSDSDPARID: TIntegerField;
    qSDSDNAME: TIBStringField;
    qSDSDISDELETE: TIntegerField;
    Label7: TLabel;
    dbgRSTabel: TcxGrid;
    tvRSTabel: TcxGridDBTableView;
    cxGridLevel2: TcxGridLevel;
    qChildren: TIBQuery;
    dsChildren: TDataSource;
    qChildrenPID: TIntegerField;
    qChildrenPP: TIBStringField;
    qChildrenSDNAME: TIBStringField;
    qChildrenPODR: TIBStringField;
    qChildrenPDATEBIRTH: TDateField;
    tvRSTabelPP: TcxGridDBColumn;
    tvRSTabelColumn1: TcxGridDBColumn;
    dxLookupTreeView1: TdxLookupTreeView;
    dxLookupTreeView2: TdxLookupTreeView;
    Label1: TLabel;
    qSD1: TIBQuery;
    dsSD1: TDataSource;
    qSD1SDNAME: TIBStringField;
    qSD1SDID: TIntegerField;
    qSD1SDPARID: TIntegerField;
    qSD1SDISDELETE: TIntegerField;
    qChildrenZAKAZ: TLargeintField;
    qChildrenPROVELI: TIntegerField;
    tvRSTabelZAKAZ: TcxGridDBColumn;
    tvRSTabelPROVELI: TcxGridDBColumn;
    procedure tvRSTabelColumn1GetDataText(Sender: TcxCustomGridTableItem;
      ARecordIndex: Integer; var AText: String);
    procedure qChildrenBeforeOpen(DataSet: TDataSet);
    procedure FormShow(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure dxLookupTreeView1CloseUp(Sender: TObject; Accept: Boolean);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmDopPodrView: TfmDopPodrView;

implementation
uses DBinv, invtypes, invproc;
{$R *.dfm}

procedure TfmDopPodrView.tvRSTabelColumn1GetDataText(
  Sender: TcxCustomGridTableItem; ARecordIndex: Integer;
  var AText: String);
var Row: integer;
begin
  inherited;
  Row := Sender.GridView.DataController.GetRowIndexByRecordIndex(ARecordIndex, False) + 1;
  AText := IntToStr(Row);

end;

procedure TfmDopPodrView.qChildrenBeforeOpen(DataSet: TDataSet);
begin
  inherited;
  qChildren.ParamByName('sdid_podr').AsInteger := qSDSDID.AsInteger;
  qChildren.ParamByName('sdid_usl').AsInteger := qSD1SDID.AsInteger;
end;

procedure TfmDopPodrView.FormShow(Sender: TObject);
begin
  inherited;
  qSD.Close;
  qSD.Open;
  qSD1.Close;
  qSD1.Open;
end;

procedure TfmDopPodrView.FormCreate(Sender: TObject);
begin
  inherited;
  ;
end;

procedure TfmDopPodrView.dxLookupTreeView1CloseUp(Sender: TObject;
  Accept: Boolean);
begin
  inherited;
  qChildren.Close;
  qChildren.Open;
end;

procedure TfmDopPodrView.FormClose(Sender: TObject;
  var Action: TCloseAction);
var  i: integer;
begin
  inherited;
  for I := ComponentCount - 1 downto 0 do
    if (Components[I] is TIBQuery) then
      if (Components[I] as TIBQuery).Active then (Components[I] as TIBQuery).Close;
end;

end.
